module game {
    export class Processor_GAME extends puremvc.SimpleCommand implements puremvc.ICommand {
        public constructor() {
            super();
        }
        public static NAME: string = "Processor_GAME";
        private gameProxy: GameProxy = null;
        /**
         * 注册消息
         */
        public register(): void {
            this.facade.registerCommand("Processor_GAME", Processor_GAME);
        }

        public execute(notification: puremvc.INotification): void {
            this.gameProxy = GameProxy.getProxy();
            var Body: any = notification.getBody();
            let msgdata: Object = DataParser.WSReceiveMsg(RegDataGame, Body);
            if (Global.isEmpty(msgdata)) {
                return;
            }
            let mainCmd = msgdata["mainCmd"];
            let subCmd = msgdata["subCmd"];
            let data = msgdata["msgData"];
            if (InstructionsEnum.IS_TEST) {
                console.log("大厅接收：", mainCmd, subCmd, msgdata)
            }
            if (Global.isEmpty(data)) {
                return;
            }
            switch (mainCmd) {
                case 1: {
                    if (subCmd == 100) {
                        this.gameProxy.login(data)
                        //登陆成功移除加载界面
                        if (egret.MainContext.instance.stage.contains(Main.loadingView)) {
                            egret.MainContext.instance.stage.removeChild(Main.loadingView);
                        }
                        //关闭登陆注册页
                        game.AppFacade.getInstance().sendNotification(PanelNotify.LOGIN.CLOSE_MAIN);
                        game.AppFacade.getInstance().sendNotification(PanelNotify.LOGIN.CLOSE_PLAYERLOGIN);
                        game.AppFacade.getInstance().sendNotification(PanelNotify.LOGIN.CLOSE_PLAYERREGISTER);
                    }
                    if (subCmd == 101) {
                        Global.tipShow(data["szDescribeString"]);
                    }
                    break;
                }
                case 2: {//返回房间列表
                    if (subCmd == 104) {
                        this.gameProxy.getRoomList(data);
                    }
                    break;
                }
                case 3: {
                    if (subCmd == 120) {//换头像
                        this.gameProxy.modifyFaceid(data);
                    }
                    if (subCmd == 164) {//查询保险箱成功
                        game.AppFacade.instance.sendNotification(PanelNotify.HALL.OPEN_SAFEBOX, data);
                    }
                    if (subCmd == 166) {//银行成功
                        this.gameProxy.cqkCg(data);

                    }
                    if (subCmd == 167) {//银行失败
                        this.gameProxy.cqkSba(data);
                    }
                    if (subCmd == 170) {//密码设置结果
                        this.gameProxy.cqkSb(data);
                    }
                    break;
                }
                case 100: {
                    if (subCmd == 101) {
                        Global.tipShow(data.szDescribeString)
                    }
                    break;
                }
                case 102: {
                    if (subCmd == 301) {//获取用户信息//废弃
                        this.gameProxy.getUserInfo(data);
                    }
                    if (subCmd == 901) {//操作失败
                        Global.tipShow(data["szDescribeString"]);
                    }
                    break;
                }
                case 104: {
                    //登陆
                    if (subCmd == 100) {
                        this.gameProxy.login(data)
                    }
                    if (subCmd == 101) {//登陆失败
                        Global.tipShow(data["szDescribeString"])
                    }
                    if (subCmd == 200) {//登陆失败
                        Global.tipShow(data["szDescribeString"])
                    }
                    break;
                }

            }
        }
    }
}
